Ext.define('AmpleHarvest.elements.combobox.cFacet', {
    extend : 'Ext.form.field.ComboBox',
    requires : [ "AmpleHarvest.DATA.Store.cFacet" ],
    uses : [
    // 'DarkOwl.User_Manager.Windows.Setup.cCreateDB',
    ],
    minChars : 1,
    anchor : "100%",
    mode : 'remote',
    forceSelection : false,
    triggerAction : 'all',
    allowBlank : true,
    selectOnFocus : true,
    typeAhead : true,
    m_str_Facet : "",
    m_str_BaseQuery : "*:*",
    m_str_SolrType : "reaper",
    m_str_Prefix : "",
    alias : [ 'widget.facetcombobox' ],

    initComponent : function () {
        this.store = Ext.create("AmpleHarvest.DATA.Store.cFacet");

        this.store.set_Facet(this.m_str_Facet);
        this.store.set_SolrType(this.m_str_SolrType);

        if (this.m_str_Prefix) {
            this.store.set_Prefix(this.m_str_Prefix);
        }

        this.callParent();

        this.on('afterrender', function (e, o) {
            // Sets the appropriate data type for choosing which solr to use.
            this.store.set_DataType(this.up("ampleharvest-objects-search-csearchwin").m_DataType);
        });

        this.on('beforequery', function (e, t, o) {
            this.store.set_BaseQuery(this.m_str_BaseQuery);
        });

        // this.on('change',function(){alert ("CHANGE!");});
        // this.on('expand',function(){alert ("EXPAND!");});

        this.on('focus', function (e, t, o) {
            this.store.set_BaseQuery(this.m_str_BaseQuery);
            this.store.load();
        });
    },

    getXType : function () {
        return "facetcombo";
    }
});